import java.util.*;

public class Main {
    public  static List<List<Integer>> generate(int numRows) {

        List<List<Integer>> ret = new ArrayList<>();
        List<Integer> row = new ArrayList<>();
        row.add(1);//第一行
        ret.add(row);//把第一行处理完
        //处理第二行以下的数据
        for (int i = 1; i < numRows; i++) {
            List<Integer> curRow = new ArrayList<>();
            curRow.add(1);
            //获取上一行
            List<Integer> preRow = ret.get(i - 1);
            for (int j = 1; j < i; j++) {
                int x = preRow.get(j) + preRow.get(j - 1);
                curRow.add(x);
            }
            //每一行的最后一个元素也是1
            curRow.add(1);
            ret.add(curRow);
        }
        return ret;
    }
    public static void main(String[] args) {
        List<List<Integer>>  ret = generate(5);

        System.out.println(ret);
    }

    public  static List<Character> func(String str1, String str2){
        List<Character>  list= new ArrayList<>();
        for (int i = 0; i < str1.length(); i++) {
            char ch = str1.charAt(i);
            if(!str2.contains(ch+"")){
                list.add(ch);
            }
        }
        return list;
    }
    public static void main4(String[] args) {
        String s1 = "hello wordow";
        String s2 = "wol";

      List<Character> list = func(s1,s2);
       /* for (char x:list) {
            System.out.print(x+" ");
        }*/

        for (int i = 0; i < list.size(); i++) {
            System.out.print(list.get(i)+" ");
        }

    }
    public static void main3(String[] args) {
        //遍历ArrayList的三种方法

        ArrayList<Integer> list2 = new ArrayList<>();
        list2.add(1);
        list2.add(2);
        list2.add(3);
        list2.add(4);
        list2.add(5);


        for (int i = 0; i < list2.size(); i++) {
            System.out.print(list2.get(i)+" ");
        }
        System.out.println();

        for(Integer x :list2) {
            System.out.print(x+" ");
        }
        System.out.println();

        System.out.println("=================");

        Iterator<Integer> it = list2.iterator();
        while (it.hasNext()) {
            System.out.print(it.next()+" ");
        }
        System.out.println();
        System.out.println("=================");

        //迭代器
        ListIterator<Integer> listIterator = list2.listIterator();
        while (listIterator.hasNext()) {
            System.out.print(listIterator.next()+" ");
        }

        System.out.println();
        System.out.println("=================");
        //从后往前遍历
        ListIterator<Integer> listIterator2 = list2.listIterator(list2.size());
        while (listIterator.hasPrevious()) {
            System.out.print(listIterator.previous()+" ");
        }
        System.out.println();

    }
    public static void main1(String[] args) {
        MyArrayList arrayList = new MyArrayList();
        arrayList.add(1);
        arrayList.add(2);
        arrayList.add(3);
        arrayList.add(4);
        arrayList.add(5);
        arrayList.add(6);

        arrayList.add(6,5);

        System.out.println(arrayList.get(6));
        arrayList.display();
    }
}